function Post(url, params) {
    var form = $("<form method='post'></form>");
    form.attr({"action": url});
    for (pa in params) {
        var input = $("<input type='hidden'>");
        input.attr({"name": pa});
        input.val(params[pa]);
        form.append(input);
    }
    $("html").append(form);
    form.submit();
}

$(document).ready(function () {
    $.ajax({
        type: "get",
        url: "/getSessionOfUserName/Data",
        success: function (data) {
            if (data != null && data !== "请登录") {
                $(".exit").show();
                console.log(data);
            }
        }
    });

    $("#search").click(function () {
        let search = $(this).siblings("input").val();
        // console.log(kind);
        Post("/index/search", {search: search});
    });

    $(".kind").click(function () {
        let kind = $(this).text();
        // console.log(kind);
        Post("/index/kind", {kind: kind});
    });

    $(".exit").click(function () {
        $.get("/exit", function (data) {
            window.location.reload();
        })
    })
});
